﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GGEditor.API;
using GGEditor.API.Plugins;

namespace GGEditor.Core.UI
{
	[XmlNodeObjectFactory(Name = "WindowManager")]
	public class WindowManagerFactory : IXmlNodeObjectFactory
	{
		#region Implementation of IXmlNodeObjectFactory

		public object Build(IPluginNode pluginNode, IDictionary<string, string> attributes)
		{
			pluginNode.ChildAdded += OnChildAdded;
			pluginNode.ChildRemoved += OnChildRemoved;
			return (pluginNode.Parent.Object as IWorkspaceForm).WindowManager;
		}

		void OnChildAdded(IPluginNode node, IPluginNode child, int position)
		{
			(node.Object as IWindowManager).CreateWindow(child.Object as WindowParameters);
		}

		void OnChildRemoved(IPluginNode node, IPluginNode child, int position)
		{

		}

		#endregion
	}
}
